CSharpTest.Net
GetEnumerator Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : GetEnumerator Method

Glossary Item Box

Returns a typed enumerator

Syntax

Visual Basic (Declaration) 
Public Function GetEnumerator() As IEnumerator(Of T)
C# 
public IEnumerator<T> GetEnumerator()

Example

Library/Library.Test/TestSetList.cs

C#Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NETCopy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys